package Hxw3DEngine.core.display
{
	import Hxw3DEngine.core.component.renderer.MeshRenderer;
	import Hxw3DEngine.asset.parsers.bson.vo.Stream;
	import Hxw3DEngine.core.materials.shader.newFilter.CoordinateFilter;
	import Hxw3DEngine.core.materials.shader.Shader3D;
	import Hxw3DEngine.core.Resource.geometry.ResourceGeometry;
	import Hxw3DEngine.core.materials.Material3D;
	
	//坐标系
	public class Coordinate extends GameObject
	{
		
		public function Coordinate():void{
			
			var zb:Number = 0.08;
			
			var vertexdata:Vector.<Number> = Vector.<Number>([
				//从原点开始从负数开始
				//x,y,z,r,g,b
				0,0.02,-zb,1,0,0,
				0,0.02,zb,1,0,0,
				100,0.02,-zb,1,0,0,
				100,0.02,zb,1,0,0,
				
				-zb,0,0,0,1,0,
				zb,0,0,0,1,0,
				0,100,0,0,1,0,
				0,100,0,0,1,0,
				
				-zb,0.02,0,0,0,1,
				zb,0.02,0,0,0,1,
				-zb,0.02,100,0,0,1,
				zb,0.02,100,0,0,1
				
			]);
			
			var indexdata:Vector.<uint> = Vector.<uint>([
				0,1,2,1,2,3,
				
				4,5,6,5,6,7,
				
				8,9,10,9,10,11
				
			]);
			
			var mesh:MeshRenderer = new MeshRenderer();
			addComponent(mesh);
			
			mesh.geometry = new ResourceGeometry();
			mesh.geometry.createFromStreams(indexdata,12,[Stream.fromVector(Stream.stream_positions | Stream.stream_colors_rgb, vertexdata)]);
			mesh.material = new Material3D;
			mesh.material.blendMode = Material3D.BLEND_NONE;
			mesh.material.twoSided = true;
			mesh.material.shader = new Shader3D([new CoordinateFilter()]);
		}
	}
}